package dao;

import java.awt.Color;
import java.util.HashMap;

/**
 * The character of the user, will move and fight in the dungeon, and speak with
 * other users characters
 */
public class UserCharacter extends Actor implements Comparable {

	public static int BASIC_LIFE = 10;
	public static int BASIC_LIFE_MAX = 10;
	public static int BASIC_ATTACK = 1;
	public static int BASIC_ARMOR = 0;
	public int life_max;

	private String pseudo;
	private Client owner;
	private Color peau;
	private Color habits;
	private Color yeux;
	private Color cheveux;
	private String sexe;
	
	public UserCharacter() {
		super(BASIC_LIFE, BASIC_ATTACK, BASIC_ARMOR);
		this.life_max = BASIC_LIFE_MAX;
	}

	/**
	 * Constructor, calls the Actor constructor
	 * 
	 * @param pseudo
	 *            the usercharacter name
	 * @param r 
	 * @see the Actor constructor
	 */
	public UserCharacter(String pseudo, int life, int life_max, int damage, int armor,
		Color peau, Color habits, Color yeux, Color cheveux, String sexe) {
		super(life, damage, armor);
		this.life_max = life_max;
		this.pseudo = pseudo;
		this.peau = peau;
		this.habits = habits;
		this.yeux = yeux;
		this.cheveux = cheveux;
		this.sexe = sexe;
	}

	/*
	 * GETTERS AND SETTERS
	 */

	public static int getBASIC_LIFE() {
		return BASIC_LIFE;
	}

	public static void setBASIC_LIFE(int bASIC_LIFE) {
		BASIC_LIFE = bASIC_LIFE;
	}

	public static int getBASIC_ATTACK() {
		return BASIC_ATTACK;
	}

	public static void setBASIC_ATTACK(int bASIC_ATTACK) {
		BASIC_ATTACK = bASIC_ATTACK;
	}

	public static int getBASIC_ARMOR() {
		return BASIC_ARMOR;
	}

	public static void setBASIC_ARMOR(int bASIC_ARMOR) {
		BASIC_ARMOR = bASIC_ARMOR;
	}

	public Color getPeau() {
		return peau;
	}

	public void setPeau(Color peau) {
		this.peau = peau;
	}

	public Color getHabits() {
		return habits;
	}

	public void setHabits(Color habits) {
		this.habits = habits;
	}

	public Color getYeux() {
		return yeux;
	}

	public void setYeux(Color yeux) {
		this.yeux = yeux;
	}

	public Color getCheveux() {
		return cheveux;
	}

	public void setCheveux(Color cheveux) {
		this.cheveux = cheveux;
	}

	public String getSexe() {
		return sexe;
	}

	public void setSexe(String sexe) {
		this.sexe = sexe;
	}

	public String getPseudo() {
		return pseudo;
	}

	public void setPseudo(String pseudo) {
		this.pseudo = pseudo;
	}

	public Room getCurrentRoom() {
		return currentRoom;
	}

	public void setCurrentRoom(Room _currentRoom) {
		this.currentRoom = _currentRoom;
	}

	public Client getOwner() {
		return owner;
	}

	public void setOwner(Client owner) {
		this.owner = owner;
	}
	
	public int getLife_max() {
		return life_max;
	}

	public void setLife_max(int life_max) {
		this.life_max = life_max;
	}

	public int getLife_actu() {
		return life;
	}

	public void setLife_actu(int life_actu) {
		this.life = life_actu;
	}
	
	// for fight order
	public HashMap<String, UserCharacter> fights = new HashMap<String, UserCharacter>();
	public boolean token = true;

	@Override
	public boolean equals(Object obj) {
		UserCharacter uc = (UserCharacter) obj;
		if (uc.compareTo(this) == 0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public String getName() {
		return this.pseudo;
	}

	public void init(Room room) {
		this.life = BASIC_LIFE;
		this.life_max = BASIC_LIFE_MAX;
		this.damage = BASIC_ATTACK;
		this.armor = BASIC_ARMOR;
		this.busyFightID = null;
		for (int i = 0; i < this.currentRoom.getWho().size(); i++) {
			if (this.currentRoom.getWho().get(i).getPseudo().equals(this.getPseudo())) {
				this.currentRoom.getWho().remove(i);
			}
		}
		this.currentRoom = room;
		//room.getWho().remove(this);
	}

	@Override
	public int compareTo(Object arg0) {
		UserCharacter cha = (UserCharacter) arg0;
		if (cha.getPseudo() == cha.getPseudo()) {
	    	return 0;
	    } else {
	    	return 1;
	    }
	}

}